package cn.mugutu.finance.controller;

import cn.mugutu.finance.annotation.SysResource;
import cn.mugutu.finance.domain.DoubleBall;
import cn.mugutu.finance.dto.BaseResult;
import cn.mugutu.finance.query.DoubleBallQuery;
import cn.mugutu.finance.service.DoubleBallService;
import cn.mugutu.finance.utils.Pager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 双色球
 * Created by gan on 2018/12/12 19:38.
 */

@Controller
@RequestMapping("/doubleball")
public class DoubleBallController extends BaseController {

    @Autowired
    private DoubleBallService doubleBallService;

    @RequestMapping("/listUI")
    @SysResource(name = "双色球历史数据页面", code = "doubleball:listui")
    public String listUI() {
        return "doubleball/list";
    }


    @RequestMapping("/list")
    @ResponseBody
    @SysResource(name = "查询双色球数据", code = "doubleball:list")
    public BaseResult.EasyUIResult<DoubleBall> list(DoubleBallQuery query, int page, int rows) {
        setEasyUIParamsInQuery(query, page, rows);
        Pager<DoubleBall> pager = doubleBallService.findByPage(query);
        return new BaseResult.EasyUIResult<DoubleBall>(pager.getTotalCount(), pager.getRows());
    }


    /**
     * 获取上期开奖号码
     */
    @RequestMapping(value = "/lastOpenNumber", method = RequestMethod.GET)
    @ResponseBody
    public BaseResult getLastOpenNumber() {
        String lastOpenNumber = doubleBallService.getLastOpenNumber();
        return new BaseResult(true,lastOpenNumber);
    }

    /**
     * 获取上期推荐开奖号码
     */
    @RequestMapping(value = "/lastOpenNumberRecomment", method = RequestMethod.GET)
    @ResponseBody
    public BaseResult getLastOpenNumberRecomment() {
        String lastOpenNumber = doubleBallService.getLastOpenNumberRecomment();
        return new BaseResult(true,lastOpenNumber);
    }

    /**
     * 获取接下来最近一期推荐开奖号码
     */
    @RequestMapping(value = "/nextRecomment", method = RequestMethod.GET)
    @ResponseBody
    public BaseResult getLastNextRecomment() {
        String nextRecomment = doubleBallService.getNextRecomment();
        return new BaseResult(true,nextRecomment);
    }



}
